import React from 'react';
import { connect } from 'dva';
import router from 'umi/router';

import { Table, Button } from 'antd';

import Link from 'umi/link'

const formPath = '/AccountConfig/ProductProductForm';
const linePath = '/AccountConfig/ProductProduct';


@connect(({ productProduct }) => ({ productProduct }))
class List extends React.Component {
  state = {
  }

  treeview = [
      {
        title: '',
        dataIndex: '_',
        render: (_, { id }) => {
          return <Link to={`${linePath}?id=${id}`}>查看</Link>;
        },
      },
      { title: '代码', dataIndex: 'default_code', },
      { title: '名称', dataIndex: 'name', },
      { title: '收益科目', dataIndex: 'property_account_income_id.name', },
      { title: '费用科目', dataIndex: 'property_account_expense_id.name', },
  ]


  async componentDidMount() {
    const { dispatch } = this.props;
    await dispatch({
      type: 'productProduct/search',
      payload: {domain:[] },

    });

  }

  gotoForm() {
      router.push(formPath);
  }

  render() {
    const { productProduct: { recordsList } } = this.props;

    return (
      <div>
        <div>存货/固定资产/无形资产/费用类的总账科目的明细科目是 产品 </div>
        <div>销售发票/采购账单/费用报销等 在生成凭证时，科目取自 产品 </div>
        <div>产品有 category_id 属性，产品类别上也可以 配置科目 </div>
        <div>销售发票上的 收入科目，取自产品</div>
        <div>采购账单上的 费用科目，取自产品</div>
        <div></div>
        <Button onClick={()=>this.gotoForm()}>新建</Button>
        <Table columns={this.treeview} dataSource={recordsList} rowKey="id" />

      </div>
    );
  }
}

export default List;





